<template>
  <div>
    <ol class="breadcrumb-nav">
  			<li>
  				<a href="">主页</a>
  			</li>
  			<li>
  				文章列表
  			</li>
  		</ol>
  		<div class="pd-20">
  			<table class="table table-h table-border table-bg table-bordered mt-20">
  				<thead>
  					<tr>
  						<th style="width:50px">序号</th>
  						<th>标题</th>
  						<th>发布时间</th>
  						<th>作者</th>
  						<th>栏目</th>
  						<th style="width:150px">操作</th>
  					</tr>
  				</thead>
  				<tbody class="text-c">
  						<tr v-for="list in article">
                <td>{{$index+1}}</td>
                <td>{{list.title}}</td>
  							<td>{{list.releaseTime}}</td>
  							<td>{{list.author}}</td>
  							<td>{{list.column}}</td>
  							<td>
                  <a v-link="{path:'/articleEdit?id='+list._id}">编辑</a>
  								<a href="javascript:;" @click="delArticle(list)" class="delete-btn">删除</a>
  							</td>
  						</tr>
  				</tbody>
  			</table>
  		</div>
  		<div class="pd-20">
  			<a v-link="{path:'/articleForm'}" class="btn btn-submit">添加文章</a>
  		</div>
  </div>
</template>
<script>
	export default{
		data(){
			return {
				article:""
			}
		},
    methods:{
      delArticle:function(data){
        config("哈哈哈");
        if(confirm("是否确认删除?")){
          var th = this;
          this.$http.post("/delArticle" , {id:data._id} , function(res){
            if(res.state == "ok"){
              th.article.$remove(data);
              alert("删除成功");
            }else{
              alert(res.message);
            };
          },"JSON");
        };
      }
    },
		route:{
			data(transition){
        this.$http.post("/getArticle" , function(data){
          transition.next({article:data.article});
        },"JSON");
			}
		}
	};
</script>
